<div id="main-content">
    <div class="container">
    	<div class="row">
    		<div id="content" class="col-lg-12">
    			<!-- PAGE HEADER-->
    			<div class="row">
    				<div class="col-sm-12">
                        <div class="page-header">
    						<div class="clearfix">
    							<h3 class="content-title pull-left">Thêm danh mục mới</h3>
    						</div>
    						<div class="description">Xin mời nhập theo mẫu bên dưới</div>
   					    </div>
   				     </div>
    			</div>
                <!-- DATA TABLES -->
						<div class="row">
							<div class="col-md-12">
								<!-- BOX -->
								<div class="box border green">
									<div class="box-title">
										<h4><i class="fa fa-table"></i>Thêm danh mục mới</h4>
										<div class="tools hidden-xs">
											<a href="javascript:;" data-toggle="tooltip" title="Ẩn đi" class="collapse">
												<i class="fa fa-chevron-up"></i>
											</a>
										</div>
									</div>
									<div class="box-body">
                                        <!-- Start Form -->
                                         <?php echo validation_errors(); ?>
                                        <form method="POST" class="form-horizontal row-border" action="<?php echo base_url().'admin/xuly/subjects/list/'.$this->uri->segment(5);?>">
										  <div class="form-group">
											 <label class="col-md-2 control-label">Tiêu đề:</label> 
											 <div class="col-md-10"><input name="title" id="title" onkeyup="locdau();" type="text" value="<?php if(!empty($data)){echo $data->title;};?>" class="form-control" /></div>
										      <!-- Node // Đặt id input là title và id alias là alias và onkeyup="locdau();" sẽ tự động chạy function alias -->
                                          </div>
                                          <div class="form-group">
											 <label class="col-md-2 control-label">Alias:</label> 
											 <div class="col-md-10"><input id="alias" name="alias"value="<?php if(!empty($data)){echo $data->alias;};?>" type="text" class="form-control" /></div>
										  </div>
                                          <div class="form-group">
											 <label class="col-md-2 control-label">Sắp xếp:</label> 
											 <div class="col-md-10"><input value="<?php if(!empty($data)){echo $data->order;}else echo '0';?>" name="order" type="text" class="form-control" /></div>
										  </div>
                                          <div class="form-group">
											 <label class="col-md-2 control-label">Danh mục:</label> 
											 <div class="col-md-10">
                                                <select name="parentid" id="input" class="form-control">
                                                <option id="0" value="0">-- Danh mục gốc --</option>
                                                        <?php $parentmenu = $this->common_model->getdata('subjects',array('publish'=>1,'parentid'=>0),array('title','id'));
                                                              if(!empty($parentmenu))
                                                              {
                                                              foreach ($parentmenu as $menu1)
                                                                {  ?>
                                                                    <option <?php if(!empty($data)) {if($data->parentid == $menu1->id) {echo 'selected="selected"';}} ?> id="<?php echo $menu1->id ?>'" value="<?php echo $menu1->id ?>">-- <?php echo $menu1->title; ?></option>';
                                                                    <?php $crmenu =$this->common_model->getdata('subjects',array('publish'=>1,'parentid'=>$menu1->id),array('title','id'));
                                                                    if(!empty($crmenu))
                                                                        {
                                                                            ?>
                                                                            <?php foreach ($crmenu as $menu2)
                                                                                {
                                                                                 ?> <option <?php if(!empty($data)) {if($data->parentid == $menu2->id) {echo 'selected="selected"';}} ?> id="<?php echo $menu2->id ?>" value="<?php echo $menu2->id ?>">----- <?php echo $menu2->title ?></option>';
                                                                                <?php }
                                                                        }
                                                                }
                                                              }
                                                         ?>
                                                </select>
                                             </div>
										  </div>
                                          <div class="form-group">
											 <label class="col-md-2 control-label">Trạng thái:</label> 
											 <div class="col-md-10">
                                                <select name="publish" id="input" class="form-control">
                                                <option <?php if(!empty($data)){if($data->publish=='1')echo 'selected="selected"';} ?> value='1'>Hiện</option> 
                                                <option <?php if(!empty($data)){if($data->publish=='0')echo 'selected="selected"';} ?> value='0'>Ẩn</option> 
                                                </select>
                                             </div>
										  </div>
                                          <div class="form-group">
													 <label class="col-md-2 control-label">Mô tả danh mục:</label> 
													 <div class="col-md-10"><textarea rows="3" cols="5" name="metades" class="form-control"><?php if(!empty($data)){echo $data->metades;};?></textarea></div>
										  </div>
                                          <div class="form-group">
													 <label class="col-md-2 control-label">Từ khóa Seo danh mục:</label> 
													 <div class="col-md-10"><textarea rows="3" cols="5" name="metakey" class="form-control"><?php if(!empty($data)){echo $data->metakey;};?></textarea></div>
										  </div>
                                          <input class="guidulieu btn btn-success" type="submit" value="Lưu"/>
										</form>
                                        <!-- End Form -->
                                    </div>
								</div>
								<!-- /BOX -->
							</div>
						</div>
						<!-- /DATA TABLES -->
    			<!-- /PAGE HEADER -->
    		</div>
    	</div>
    </div>
</div>